1 /**
2  * This file is part of libphidget21
3  *
4  * Copyright 2006-2015 Phidgets Inc <patrick@phidgets.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see 
18  * <http://www.gnu.org/licenses/>
19  */
20 module phidget21.phidmanager;
21 import phidget21.phidcommon : CPhidgetHandle;
22 
23 extern(C) __gshared {
24 	/**
25      * A Phidget Manager handle.
26      */
27 	struct _CPhidgetManager;
28 	alias CPhidgetManagerHandle = _CPhidgetManager*;
29 
30 	int function(CPhidgetManagerHandle* phidm) CPhidgetManager_create;
31 	int function(CPhidgetManagerHandle phidm) CPhidgetManager_open;
32 	int function(CPhidgetManagerHandle phidm) CPhidgetManager_close;
33 	int function(CPhidgetManagerHandle phidm) CPhidgetManager_delete;
34 
35 	alias CPhidgetManager_set_OnAttach_Handler_Func = extern(C) int function(CPhidgetHandle phid, void* userPtr);
36 	int function(CPhidgetManagerHandle phidm, CPhidgetManager_set_OnAttach_Handler_Func fptr, void* userPtr) CPhidgetManager_set_OnAttach_Handler;
37 
38 	alias CPhidgetManager_set_OnDetach_Handler_Func = extern(C) int function(CPhidgetHandle phid, void* userPtr);
39 	int function(CPhidgetManagerHandle phidm, CPhidgetManager_set_OnDetach_Handler_Func fptr, void* userPtr) CPhidgetManager_set_OnDetach_Handler;
40 
41 	int function(CPhidgetManagerHandle phidm, CPhidgetHandle** phidArray, int* count) CPhidgetManager_getAttachedDevices;
42 	int function(CPhidgetHandle* phidArray) CPhidgetManager_freeAttachedDevicesArray;
43 
44 	alias CPhidgetManager_set_OnError_Handler_Func = extern(C) int function(CPhidgetManagerHandle phidm, void* userPtr, int errorCode, const char* errorString);
45 	int function(CPhidgetManagerHandle phidm, CPhidgetManager_set_OnError_Handler_Func fptr, void* userPtr) CPhidgetManager_set_OnError_Handler;
46 
47 	alias CPhidgetManager_set_OnServerConnect_Handler_Func = extern(C) int function(CPhidgetManagerHandle phidm, void* userPtr);
48 	int function(CPhidgetManagerHandle phidm, CPhidgetManager_set_OnServerConnect_Handler_Func fptr, void* userPtr) CPhidgetManager_set_OnServerConnect_Handler;
49 
50 	alias CPhidgetManager_set_OnServerDisconnect_Handler_Func = extern(C) int function(CPhidgetManagerHandle phidm, void* userPtr);
51 	/**
52 	 * Sets a server disconnect handler callback function. This is used for opening Phidget Managers remotely, and is called when a connection to the server has been lost.
53 	 * 
54 	 * Params:
55 	 *  phidm = A phidget manager handle.
56 	 *  fptr = Callback function pointer.
57 	 *  userPtr = A pointer for use by the user - this value is passed back into the callback function.
58 	 */
59 	int function(CPhidgetManagerHandle phidm, CPhidgetManager_set_OnServerDisconnect_Handler_Func fptr, void* userPtr) CPhidgetManager_set_OnServerDisconnect_Handler;
60 
61 	/**
62 	 * Gets the server ID of a remotely opened Phidget Manager. This will fail if the manager was opened locally.
63 	 * 
64 	 * Params:
65 	 *  phidm = A connected phidget manager handle.
66 	 *  serverID = A pointer which will be set of a char array containing the server ID string.
67 	 */
68 	int function(CPhidgetManagerHandle phidm, const char** serverID) CPhidgetManager_getServerID;
69 
70 	/**
71 	 * Gets the address and port of a remotely opened Phidget Manager. This will fail if the manager was opened locally.
72 	 * 
73 	 * Params:
74 	 *  phidm = A connected phidget manager handle.
75 	 *  address = A pointer which will be set to a char array containing the address string.
76 	 *  port = An int pointer for returning the port number.
77 	 */
78 	int function(CPhidgetManagerHandle phidm, const char** address, int* port) CPhidgetManager_getServerAddress;
79 
80 	/**
81 	 * Gets the connected to server status of a remotely opened Phidget Manager. This will fail if the manager was opened locally.
82 	 * 
83 	 * Params:
84 	 *  phidm = An opened phidget manager handle.
85 	 *  serverStatus = An int pointer for returning the server status. Possible codes are PHIDGET_ATTACHED and PHDIGET_NOTATTACHED.
86 	 */
87 	int function(CPhidgetManagerHandle phidm, int* serverStatus) CPhidgetManager_getServerStatus;
88 
89 	/**
90 	 * Opens a Phidget manager remotely by ServerID. Note that this rquires Bonjour (mDNS) to be running on both the host and the server.
91 	 * 
92 	 * Params:
93 	 *  phidm = A phidget manager handle.
94 	 *  serverID = ServerID. Specify NULL to open any.
95 	 *  password = Password. Can be NULL if the server is running unsecured.
96 	 */
97 	int function(CPhidgetManagerHandle phidm, const char* serverID, const char* password) CPhidgetManager_openRemote;
98 
99 	/**
100 	 * Opens a Phidget manager remotely by address and port.
101 	 * 
102 	 * Params:
103 	 *  phidm = A phidget manager handle.
104 	 *  address = Address. This can be a hostname or IP address.
105 	 *  port = Port number. Default is 5001.
106 	 *  password = Password. Can be NULL if the server is running unsecured.
107 	 */
108 	int function(CPhidgetManagerHandle phidm, const char* address, int port, const char* password) CPhidgetManager_openRemoteIP;
109 
110 }